import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/home',
    name: 'Home',
    children: [{
      path: 'home',
      component: () => import('@/views/home/index'),
      meta: { title: '控制台', icon: 'dashboard' }
    }]
  },

  // {
  //   path: '/user',
  //   component: Layout,
  //   name: 'User',
  //   children: [{
  //     path: 'user',
  //     component: () => import('@/views/user/index'),
  //     meta: { title: '用户中心', icon: 'dashboard' }
  //   }]
  // },

  {
    path: '/data',
    component: Layout,
    redirect: '/data/upload',
    name: 'Example',
    meta: { title: '数据管理', icon: 'example' },
    children: [
      {
        path: 'upload',
        name: 'Upload',
        component: () => import('@/views/upload/index'),
        meta: { title: '上传数据', icon: 'upload' }
      },
      {
        path: 'list',
        name: 'List',
        component: () => import('@/views/list/index'),
        meta: { title: '上传记录', icon: 'list' }
      }
    ]
  },

  {
    path: '/demo',
    component: Layout,
    redirect: '/demo/cibn/pane1001',
    name: 'Demo',
    hidden: true,
    meta: { title: 'Demo', icon: 'example' },
    children: [
      {
        path: 'cibn',
        name: 'Cibn',
        redirect: '/demo/cibn/pane1001',
        component: () => import('@/views/demo/cibn/index'),
        meta: { title: 'CIBN', icon: 'analysis' },
        children: [
          {
            path: 'pane1001',
            name: 'Pane1001',
            component: () => import('@/views/demo/cibn/pane1001'),
            meta: { title: '实时数据看板', icon: 'analysis' }
          },
          {
            path: 'pane1002',
            name: 'Pane1002',
            component: () => import('@/views/demo/cibn/pane1002'),
            meta: { title: '平台运营看板', icon: 'analysis' }
          }
        ]
      }
    ]
  },

  {
    path: '/analysis',
    component: Layout,
    redirect: '/analysis/index',
    name: 'Analysis',
    meta: { title: '数据分析', icon: 'example' },
    children: [
      {
        path: 'index',
        name: 'Index',
        component: () => import('@/views/analysis/index'),
        meta: { title: '应用分析', icon: 'analysis' }
      },
      {
        path: 'list',
        name: 'analysisList',
        component: () => import('@/views/analysis/list'),
        meta: { title: '分析记录', icon: 'list' }
      }
    ]
  },

  {
    path: '/account',
    component: Layout,
    redirect: '/account/wallet',
    name: 'Account',
    meta: { title: '我的资产', icon: 'account' },
    children: [
      {
        path: 'wallet',
        name: 'Wallet',
        component: () => import('@/views/wallet/index'),
        meta: { title: '我的钱包', icon: 'wallet' }
      },
      {
        path: 'recharge',
        name: 'Recharge',
        component: () => import('@/views/wallet/recharge/index'),
        meta: { title: '充值', icon: 'recharge' },
        hidden: true
      },
      {
        path: 'cash',
        name: 'Cash',
        component: () => import('@/views/wallet/cash/index'),
        meta: { title: '提现', icon: 'cash' },
        hidden: true
      }
    ]
  },

  {
    path: '/setting',
    component: Layout,
    redirect: '/setting/pwdlogin',
    name: 'Setting',
    meta: { title: '基础设置', icon: 'setting' },
    children: [
      {
        path: 'pwdlogin',
        name: 'Pwdlogin',
        component: () => import('@/views/setting/pwdlogin/index'),
        meta: { title: '设置登录密码', icon: 'pwdlogin' }
      },
      {
        path: 'pwdpay',
        name: 'Pwdpay',
        component: () => import('@/views/setting/pwdpay/index'),
        meta: { title: '设置支付密码', icon: 'pwdpay' }
      }
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
